package log 
{
	import flash.text.TextField;
	/**
	 * ...
	 * @author FireKnight
	 */
	public final class TimeRecorder 
	{
		private static var startTime:Date;
		
		public static function getNowTime():String
		{
			var date:Date=new Date();
			return (date.month+1).toString()+"/"+date.day+" "+date.hours+"."+date.minutes+":"+date.milliseconds;
		}
		
		public static function start(message:String, field:TextField = null):void 
		{
			startTime = new Date();
			var string:String = ">> start time : " + startTime + ",\n\tof " + message + "\n\t\t-----------";
			if (field)
				field.text = string;
			trace(string);
		}
		
		public static function end(message:String, field:TextField = null):Number
		{
			var now:Date = new Date();
			var duration:Number = (now.getTime() - startTime.getTime()) / 1000;
			var string:String = ">> duration : " + duration + " sec,\n\tof " + message + "\n\t\t-----------";
			if (field)
				field.text = string;
			trace(string);
			return duration;
		}
	}
	
}